<!--
* @description 抖音数据导入
* @fileName dy_json.vue
* @author huangyu
* @date 2021/07/30 14:07:40
!-->
<template>
    <div>
        <el-form label-width="120px">
            <el-form-item label="导入类型：">
                <el-select v-model="type">
                    <el-option value="1001" label="抖音视频"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="导入内容：">
               <el-input v-model="content" type="textarea" :rows="30"></el-input>
            </el-form-item>
            <el-form-item label="">
                <el-button type="danger" plain @click="UploadExcelBtn">导入</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
// import {get} from '@/common/app.js'
export default {
    components: {},
    data() {
        return {
            list: [],
            type: '1001',
            content: '',
        }
    },
    mounted() {

    },
    methods: {
        UploadExcelBtn(){
            // console.log("aaa")
            let list = JSON.parse(this.content)
            let data = []
            if(list.length>0){
                list.forEach(item=>{
                    data.push({
                        aweme_id: item.aweme_info.aweme_id,//id
                        aweme_cover: item.aweme_info.aweme_cover,//视频图片
                        aweme_title: item.aweme_info.aweme_title,//标题
                        aweme_url: item.aweme_info.aweme_url,//链接
                        digg_count: item.aweme_info.digg_count,//点赞数
                        share_count: item.aweme_info.share_count,//分享数
                        comment_count: item.aweme_info.comment_count,//评论数
                        aweme_create_time: item.aweme_info.aweme_create_time,//发布时间
                        update_time: item.aweme_info.update_time,//更新时间
                        avatar: item.author_info.avatar,//达人头像
                        nickname: item.author_info.nickname,//达人名字
                        unique_id: item.author_info.unique_id,//达人id
                    })
                })
            }
            let params = {
                type: this.type,
                data: data,
            }
            this.get('tools_index',params).then(res=>{
                if(res.data){
                    this.$message.success("添加成功")
                    // this.$router.go(0)
                }
            })
        },
    },
}
</script>

<style scoped>

</style>